﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LabTask2Sharp
{
    public partial class FormMain : Form
    {
        private ConstraintSatisfaction csp = new ConstraintSatisfaction();
        public FormMain()
        {
            InitializeComponent();
            InitRooms();
            InitNear();
            InitPersons();
            if (!csp.Allocate())
                MessageBox.Show("Test");
            richTextBox1.Text = csp.ListAllocations();
            if (!csp.Allocate(false))
                MessageBox.Show("Test");
            richTextBox2.Text = csp.ListAllocations();
        }

        private void InitRooms()
        {
            csp.Rooms.Add(new Room("T1", 2, 5));
            csp.Rooms.Add(new Room("T2", 3, 2));
            csp.Rooms.Add(new Room("T3", 1, 3));
            csp.Rooms.Add(new Room("T4", 1, 3));
            csp.Rooms.Add(new Room("T5", 2, 5));
            csp.Rooms.Add(new Room("T6", 2, 5));
            csp.Rooms.Add(new Room("T7", 2, 5));
        }
        private void InitNear()
        {
            csp.SetRoomNear("T1", new List<string>() { "T2", "T7" });
            csp.SetRoomNear("T2", new List<string>() { "T1", "T3", "T6" });
            csp.SetRoomNear("T3", new List<string>() { "T2", "T4", "T5" });
            csp.SetRoomNear("T4", new List<string>() { "T3", "T5" });
            csp.SetRoomNear("T5", new List<string>() { "T6", "T4", "T3" });
            csp.SetRoomNear("T6", new List<string>() { "T5", "T7", "T2" });
            csp.SetRoomNear("T7", new List<string>() { "T6", "T1" });
        }

        private void InitPersons()
        {
            csp.Persons.Add(new Person("A", Person.Professions.Boss, true, 5));
            csp.Persons.Add(new Person("B", Person.Professions.Secretary, false, 1));
            csp.Persons.Add(new Person("C", Person.Professions.ItSupport, false, 2));
            csp.Persons.Add(new Person("D", Person.Professions.Boss, true, 5));
            csp.Persons.Add(new Person("E", Person.Professions.Secretary, false, 1));
            csp.Persons.Add(new Person("F", Person.Professions.Worker, false, 3));
            csp.Persons.Add(new Person("G", Person.Professions.Worker, false, 2));
            csp.Persons.Add(new Person("H", Person.Professions.Worker, true, 0));
            csp.Persons.Add(new Person("I", Person.Professions.Worker, true, 1));
        }
       
    }
}
